﻿@model List<ForumEngine.Models.SectionModel>

@using ForumEngine.Tools

@foreach (var section in Model)
{
    <div class="section">
        <div class="title">
            @if (string.IsNullOrEmpty(section.Url))
            {
                @(section.Name)
            }
            else
            {
                <a href="@(section.Url)">@(section.Name)</a>
            }
        </div>
        <div class="content">
            <table>
                @foreach (var forum in section.Forums)
                {
                    <tr class="forum">
                        <td class="icon">
                            @if (forum.HasNewPosts)
                            {
                                <img src="@Url.Content("~/Content/images/forum_new.png")" alt="New Posts"/>
                            }
                            else
                            {
                                <img src="@Url.Content("~/Content/images/forum_nonew.png")" alt="No New Posts"/>
                            }
                        </td>
                        <td class="text">
                            <div class="name"><a href="@forum.Url">@forum.Name</a></div>
                            <div class="description">@forum.Description</div>
                            <div class="moderators">
                                <span>Moderators: </span>
                                @if (forum.Moderators.Any())
                                {
                                    foreach (var moderator in forum.Moderators)
                                    {
                                        @Html.Partial("UserLinkPartial", moderator)
                                    }
                                }
                                else
                                {
                                    <text>Not defined</text>
                                }
                            </div>
                        </td>
                        <td class="threads"><span>@forum.Threads Threads</span></td>
                        <td class="posts"><span>@forum.Posts Posts</span></td>
                        <td class="last-post">
                            @if (forum.LastAuthor != null)
                            {
                                <div class="title">Last Post: <a href="@forum.LastPostUrl">@forum.LastPostTitle</a></div>
                                <div class="author">From @Html.Partial("UserLinkPartial", forum.LastAuthor)</div>
                                <div class="date">@DateTimeHelper.GetDateTime(forum.LastPostTime, true)</div>
                            }
                            else
                            {
                                <text>&nbsp;</text>
                            }
                        </td>
                    </tr>
                }
            </table>
        </div>
    </div>
}
